<!DOCTYPE html />
<?php ini_set('display_errors', 'on'); require("../db.php"); ?>

<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Ontō Project</title>
  <link rel="stylesheet" type="text/css" media="all" href="/style/site.css" />
   <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
</head>
<body>
  <div id="content">
    <h1><a href="/ontomon/">Ontomon</a></h1>
    <?php
      $termset = $db->v_termsets->where('termset', $_REQUEST['termset'])->fetch();
      if (@$_REQUEST['version']) {
        $data = $db->ontomon_data()->where('version_id',$_REQUEST['version'])->where('termset',$_REQUEST['termset']);
      } else {
        $data = $db->v_ontomon_data_current()->where('termset',$_REQUEST['termset']);
      }
    ?>

    <h2><?php echo $termset['display_name'] ?></h2>
    
    <script type="text/javascript">
      mode = 'single';
      dataRaw = <?php echo json_encode(array_map('iterator_to_array', iterator_to_array($data)))?>;
      fieldInfo = <?php echo json_encode(array_map('iterator_to_array', iterator_to_array($db->ontomon_fields())))?>;
    </script>
        
    <script type="text/javascript" src="/static/js/raphael-min.js"></script>
    <script type="text/javascript" src="/static/js/jquery-1.5.min.js"></script>
    <script type="text/javascript" src="/static/js/raphael-radar.js"></script>
    <script type="text/javascript" src="/static/js/ontograph.js"></script>
    <script type="text/javascript" src="/static/js/sprintf.js"></script>
    
    
    <script type="text/javascript">
      paper_width=960; paper_height=800;
      chart_width=500; chart_height=400; chart_radius=250;
    </script>
    

    <div class="big-ontomon" id="<?php echo $termset['termset'] ?>"></div>
    
    <div id="slider"></div>
    
    <div class="versions">
      <h2>Values</h2>
      <table id="value_table">
        <tr><th>Field</th><th>Value</th><th>Scaled Value</th></tr>
      </table>
    </div>
    <div class="versions">
      <h2>Versions</h2>
      <ul>
      <?php foreach ($db->ontomon_versions->where('termset', $_REQUEST['termset']) as $version): ?>
        <li><a href="/ontomon/termsets/<?php echo $_REQUEST['termset'] ?>/versions/<?php echo $version['version_id'] ?>/">
          <?php echo $version['create_date'] ?: $version['version_id'] ?>
        </a></li>
      <?php endforeach; ?>
    </ul>
    </div>
  </div>
</body>
